-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contrib: add a keyboard layout per window script #4504
Conversation
I believe stored layouts should be removed on By the way, does this work with multiple seats? |
import i3ipc | ||
|
||
ipc = i3ipc.Connection() | ||
prev_focused = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use current window id ipc.get_tree().find_focused().id
?
# Save current layout | ||
layouts = {} | ||
for input in ipc.get_inputs(): | ||
layouts[input.identifier] = input.xkb_active_layout_index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating layouts
uninitialized is unnecessary here, you can create them initialized as:
layouts = {input.identifier : input.xkb_active_layout_index
for input in ipc.get_inputs()}
And it's faster as a bonus.
048aada
to
2acee22
Compare
No |
If we consider this PR as a replacement to #3155, then per-seat functional needs to be implemented, because, clearly, the replacement needs to be at least as good as the one supposed to get replaced. |
I think, this script isn't supposed to be the catch-all solution for everyone. Personally, I'm going to create another one that saves the layout data on disk and restores it after restart and also has some other nice features (uses asyncio with i3ipc-python instead of the old API for example). |
This is not supposed to be a replacement. This is supposed to be an alternate solution. To be honest, I won't even be using it myself, the goal here is just to give a hint for people who want this feature. Feel free to improve it if you want multi-seat or other features. Full disclaimer: I don't personally care if this gets merged or not. But if you're so salty about it, I'd suggest to completely ignore this PR. |
I don't understand what you mean. I didn't say anything wrong or bad, did I? My assumption that this PR was supposed to be a replacement didn't appear out of pure air, it were your words #3155 (comment), quoting:
I'm sorry if I was confused, and these 2 PRs supposed to co-exist. Although I wonder then, why would you post this reply (the one I quoted). |
Sorry, I've had enough of this. I'm dropping the ball. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
if event.container.id in windows: | ||
for (input_id, layout_index) in windows[event.container.id].items(): | ||
if layout_index != layouts[input_id]: | ||
ipc.command("input \"{}\" xkb_switch_layout {}".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipc.command("input \"{}\" xkb_switch_layout {}".format( | |
ipc.command("""input "{}" xkb_switch_layout {}""".format( |
maybe this is more readable, the back slashes really threw me off
Fixes #2361